package uk.ac.bath.machine.bool;  
import uk.ac.bath.base.VectorState;
import java.io.*;
import uk.ac.bath.base.Operator;

public class Diff extends Operator {

    double last;

    public void tick(VectorState in,VectorState out) {
	double nxt = in.at(1).val;
	out.at(0).set(Math.max(nxt-last,0.0));
	last=nxt;
    }


    public void tick(VectorState in,VectorState out,int map[]) {
	double nxt = in.v[map[1]].val;
	out.v[map[0]].set(Math.max(nxt-last,0.0));
	last=nxt;
    }

    public int getStateSize() {
        return 2;
    }

    public int getParamSize() {
        return 2;
    }

    
    public Object clone() {
        return new Diff();   // this has state
    }

    public void toString(StringWriter w) {
        w.write("Diff ");
    }

}
